package com.jic.member.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MememberIntegralOrderIncrement;
import com.jic.member.mapper.MememberIntegralOrderIncrementMapper;
import com.jic.member.service.MememberIntegralOrderIncrementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员积分规则下单-充值赠送递增表
 * @author : 
 * @email : 
 * @since : 2020-04-02 03:33:22
 * @version : v1.0.0
 */
@Service
public class MememberIntegralOrderIncrementServiceImpl implements MememberIntegralOrderIncrementService {

    @Autowired
    private MememberIntegralOrderIncrementMapper mememberIntegralOrderIncrementMapper;

    @Override
    public long insert(MememberIntegralOrderIncrement mememberIntegralOrderIncrement) {
        long flag = mememberIntegralOrderIncrementMapper.insert(mememberIntegralOrderIncrement);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberIntegralOrderIncrementMapper.delete(id);
    }

    @Override
    public long update(MememberIntegralOrderIncrement mememberIntegralOrderIncrement) {
        return mememberIntegralOrderIncrementMapper.update(mememberIntegralOrderIncrement);
    }

    @Override
    public MememberIntegralOrderIncrement queryByPrimaryKey(Long id){
        return mememberIntegralOrderIncrementMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MememberIntegralOrderIncrement> query(MememberIntegralOrderIncrement mememberIntegralOrderIncrement){
        return mememberIntegralOrderIncrementMapper.query(mememberIntegralOrderIncrement);
    }

    @Override
    public PageResult<MememberIntegralOrderIncrement> queryPage(MememberIntegralOrderIncrement mememberIntegralOrderIncrement, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberIntegralOrderIncrement> list = mememberIntegralOrderIncrementMapper.queryPage(startIndex, pageQuery.getLimit(), mememberIntegralOrderIncrement);
        long count = mememberIntegralOrderIncrementMapper.queryPageCount(mememberIntegralOrderIncrement);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}